package com.dsx.test.exception;


import com.dsx.common.bean.Response;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.validation.ValidationException;


/**
 * Created by tianwenqing on 2017/5/11.
 */
@Controller
public class ExcetionController {


    @RequestMapping("/paramValid")
    @ResponseBody
    public Response paramValid(@RequestParam(required = false) String name ){
        if(StringUtils.isBlank(name)){
            throw new ValidationException("nameU不能为空");
        }
        return new Response().success();
    }

    @RequestMapping(value = "/methodValid" ,method = RequestMethod.POST)
    @ResponseBody
    public Response MethodValid(@RequestParam(required = false) String name ){
        return new Response().success();
    }

    @RequestMapping("/test500")
    @ResponseBody
    public Response test500(@RequestParam(required = false) String name ){
        if(StringUtils.isBlank(name)){
            throw  new NullPointerException("kongzhizhen");
        }
        return new Response().success();
    }


}
